unit USearchCustomer;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
  System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs,
  FMX.StdCtrls, UDialog, FMX.Edit, FMX.ListBox, FMX.Layouts, FMX.Grid, Data.Db,
  ColumnAlign, DataLayer, Data.SqlExpr, System.Generics.Collections,
  Data.FMTBcd, Xml.XMLIntf,Xml.XMLDoc,Datasnap.DBClient,
  FMX.Objects;

type
  TSearchCustomer = class(TDialogFrame)
    StringGrid1: TStringGrid;
    Label1: TLabel;
    Label2: TLabel;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    ListBoxItem4: TListBoxItem;
    ListBoxItem5: TListBoxItem;
    ListBoxItem6: TListBoxItem;
    ListBoxItem7: TListBoxItem;
    ListBoxItem8: TListBoxItem;
    ListBoxItem9: TListBoxItem;
    ListBoxItem10: TListBoxItem;
    ListBoxItem11: TListBoxItem;
    procedure ComboBox1Change(Sender: TObject);

  private
    { Private declarations }
    vipnocol, vipnamecol, telecol, streetnocol, addresscol, suburbcol,
      postcodecol: TTextColumn;

  public
    { Public declarations }
    TDataModule: TDataModule1;
    constructor Create(ParentForm: TForm; ParentPanel: TPanel;
      CallBackProc: IProcessDialogResult);
  end;

  TCustomerGrid = class
  private
    tvipno, tvipname, ttele, tstreetno, taddress, tsuburb, tpostcode: String;

  end;

var
  SearchCustomer: TSearchCustomer;
  gridlist: TList<TCustomerGrid>;

implementation

{$R *.fmx}

uses UModel;

procedure TSearchCustomer.ComboBox1Change(Sender: TObject);
var
  i: Integer;
begin
  case ComboBox1.ItemIndex of
    0:
      begin
        for i := 0 to StringGrid1.RowCount do
        begin
          if StringGrid1.Cells[0,i] = Edit1.Text then

        end;
      end;

  end;

end;

constructor TSearchCustomer.Create(ParentForm: TForm; ParentPanel: TPanel;
  CallBackProc: IProcessDialogResult);
var
  q: TClientDataSet;
  i: Integer;
  vipnoList: TList<string>;
  strgrid: TStringGrid;

begin
  inherited Create(ParentForm, ParentPanel, CallBackProc);
  // Initalize StringGrid1 columns
  vipnocol := TTextColumn.Create(StringGrid1);
  vipnamecol := TTextColumn.Create(StringGrid1);
  telecol := TTextColumn.Create(StringGrid1);
  streetnocol := TTextColumn.Create(StringGrid1);
  addresscol := TTextColumn.Create(StringGrid1);
  suburbcol := TTextColumn.Create(StringGrid1);
  postcodecol := TTextColumn.Create(StringGrid1);

  vipnocol.TextAlign := TTextAlign.taLeading;
  vipnamecol.TextAlign := TTextAlign.taLeading;
  telecol.TextAlign := TTextAlign.taLeading;
  streetnocol.TextAlign := TTextAlign.taLeading;
  addresscol.TextAlign := TTextAlign.taLeading;
  suburbcol.TextAlign := TTextAlign.taLeading;
  postcodecol.TextAlign := TTextAlign.taLeading;

  vipnocol.Parent := StringGrid1;
  vipnamecol.Parent := StringGrid1;
  telecol.Parent := StringGrid1;
  streetnocol.Parent := StringGrid1;
  addresscol.Parent := StringGrid1;
  suburbcol.Parent := StringGrid1;
  postcodecol.Parent := StringGrid1;

  vipnocol.Width := 60;
  vipnamecol.Width := 120;
  telecol.Width := 120;
  streetnocol.Width := 90;
  addresscol.Width := 160;
  suburbcol.Width := 80;
  postcodecol.Width := 78;

  vipnocol.Header := '   VIP No.';
  vipnamecol.Header := '           VIP Name';
  telecol.Header := '          TelePhone';
  streetnocol.Header := '  Street Number';
  addresscol.Header := '                  Address';
  suburbcol.Header := '      Suburb';
  postcodecol.Header := '    Post Code';

  // Initalize StringGrid1 Data
  i := 0;
  q := UModel.ClientDataSet;
  q.XMLData := UModel.proxy.GetVIPTable;
  strgrid := StringGrid1;
  Label2.Text := 'Search by ' + ComboBox1.Selected.Text;
  while not q.eof do
  begin
    q.FieldByName('VIPNo').AsString;

    StringGrid1.Cells[0, i] := q.FieldByName('VIPNo').AsString;
    StringGrid1.Cells[1, i] := q.FieldByName('VIPName').AsString;
    StringGrid1.Cells[2, i] := q.FieldByName('Telephone').AsString;
    StringGrid1.Cells[3, i] := q.FieldByName('Number').AsString;
    StringGrid1.Cells[4, i] := q.FieldByName('Address').AsString;
    StringGrid1.Cells[5, i] := q.FieldByName('Suburb').AsString;
    StringGrid1.Cells[6, i] := q.FieldByName('PostCode').AsString;
    i := i + 1;
    q.Next;

  end;

end;

end.
